using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using C1.Win.C1TrueDBGrid;
using PCSComSale.Order.BO;
using PCSComUtils.Common;
using PCSComUtils.PCSExc;
using PCSUtils.Log;
using PCSUtils.Utils;

namespace PCSSale.Order
{
	/// <summary>
	/// Summary description for SOAvoidDupleSaleOrdersDelivery.
	/// </summary>
	public class SOAvoidDupleSaleOrdersDelivery : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ComboBox cboYear;
		private System.Windows.Forms.ComboBox cboMonth;
		private System.Windows.Forms.Label lblYear;
		private System.Windows.Forms.Label lblMonth;
		private System.Windows.Forms.TextBox txtCustomer;
		private System.Windows.Forms.Label lblCustomer;
		private System.Windows.Forms.Button btnCustomer;
		private System.Windows.Forms.TextBox txtCustomerName;
		private System.Windows.Forms.Button btnSearch;
		private System.Windows.Forms.Button btnSave;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private C1.Win.C1TrueDBGrid.C1TrueDBGrid dgrdData;
		private const string THIS = "PCSSale.Order.SOAvoidDupleSaleOrdersDelivery";
		private System.Windows.Forms.Button btnClose;		
		private DataTable dtbGridLayOut;
		private DataTable dtbData;
		private const string SELECT = "Selected";
		public SOAvoidDupleSaleOrdersDelivery()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SOAvoidDupleSaleOrdersDelivery));
			this.cboYear = new System.Windows.Forms.ComboBox();
			this.cboMonth = new System.Windows.Forms.ComboBox();
			this.lblYear = new System.Windows.Forms.Label();
			this.lblMonth = new System.Windows.Forms.Label();
			this.txtCustomer = new System.Windows.Forms.TextBox();
			this.lblCustomer = new System.Windows.Forms.Label();
			this.btnCustomer = new System.Windows.Forms.Button();
			this.txtCustomerName = new System.Windows.Forms.TextBox();
			this.btnSearch = new System.Windows.Forms.Button();
			this.dgrdData = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			this.btnSave = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).BeginInit();
			this.SuspendLayout();
			// 
			// cboYear
			// 
			this.cboYear.AccessibleDescription = resources.GetString("cboYear.AccessibleDescription");
			this.cboYear.AccessibleName = resources.GetString("cboYear.AccessibleName");
			this.cboYear.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("cboYear.Anchor")));
			this.cboYear.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cboYear.BackgroundImage")));
			this.cboYear.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("cboYear.Dock")));
			this.cboYear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboYear.Enabled = ((bool)(resources.GetObject("cboYear.Enabled")));
			this.cboYear.Font = ((System.Drawing.Font)(resources.GetObject("cboYear.Font")));
			this.cboYear.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("cboYear.ImeMode")));
			this.cboYear.IntegralHeight = ((bool)(resources.GetObject("cboYear.IntegralHeight")));
			this.cboYear.ItemHeight = ((int)(resources.GetObject("cboYear.ItemHeight")));
			this.cboYear.Location = ((System.Drawing.Point)(resources.GetObject("cboYear.Location")));
			this.cboYear.MaxDropDownItems = ((int)(resources.GetObject("cboYear.MaxDropDownItems")));
			this.cboYear.MaxLength = ((int)(resources.GetObject("cboYear.MaxLength")));
			this.cboYear.Name = "cboYear";
			this.cboYear.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("cboYear.RightToLeft")));
			this.cboYear.Size = ((System.Drawing.Size)(resources.GetObject("cboYear.Size")));
			this.cboYear.TabIndex = ((int)(resources.GetObject("cboYear.TabIndex")));
			this.cboYear.Text = resources.GetString("cboYear.Text");
			this.cboYear.Visible = ((bool)(resources.GetObject("cboYear.Visible")));
			// 
			// cboMonth
			// 
			this.cboMonth.AccessibleDescription = resources.GetString("cboMonth.AccessibleDescription");
			this.cboMonth.AccessibleName = resources.GetString("cboMonth.AccessibleName");
			this.cboMonth.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("cboMonth.Anchor")));
			this.cboMonth.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cboMonth.BackgroundImage")));
			this.cboMonth.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("cboMonth.Dock")));
			this.cboMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboMonth.Enabled = ((bool)(resources.GetObject("cboMonth.Enabled")));
			this.cboMonth.Font = ((System.Drawing.Font)(resources.GetObject("cboMonth.Font")));
			this.cboMonth.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("cboMonth.ImeMode")));
			this.cboMonth.IntegralHeight = ((bool)(resources.GetObject("cboMonth.IntegralHeight")));
			this.cboMonth.ItemHeight = ((int)(resources.GetObject("cboMonth.ItemHeight")));
			this.cboMonth.Location = ((System.Drawing.Point)(resources.GetObject("cboMonth.Location")));
			this.cboMonth.MaxDropDownItems = ((int)(resources.GetObject("cboMonth.MaxDropDownItems")));
			this.cboMonth.MaxLength = ((int)(resources.GetObject("cboMonth.MaxLength")));
			this.cboMonth.Name = "cboMonth";
			this.cboMonth.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("cboMonth.RightToLeft")));
			this.cboMonth.Size = ((System.Drawing.Size)(resources.GetObject("cboMonth.Size")));
			this.cboMonth.TabIndex = ((int)(resources.GetObject("cboMonth.TabIndex")));
			this.cboMonth.Text = resources.GetString("cboMonth.Text");
			this.cboMonth.Visible = ((bool)(resources.GetObject("cboMonth.Visible")));
			// 
			// lblYear
			// 
			this.lblYear.AccessibleDescription = resources.GetString("lblYear.AccessibleDescription");
			this.lblYear.AccessibleName = resources.GetString("lblYear.AccessibleName");
			this.lblYear.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblYear.Anchor")));
			this.lblYear.AutoSize = ((bool)(resources.GetObject("lblYear.AutoSize")));
			this.lblYear.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblYear.Dock")));
			this.lblYear.Enabled = ((bool)(resources.GetObject("lblYear.Enabled")));
			this.lblYear.Font = ((System.Drawing.Font)(resources.GetObject("lblYear.Font")));
			this.lblYear.ForeColor = System.Drawing.Color.Maroon;
			this.lblYear.Image = ((System.Drawing.Image)(resources.GetObject("lblYear.Image")));
			this.lblYear.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblYear.ImageAlign")));
			this.lblYear.ImageIndex = ((int)(resources.GetObject("lblYear.ImageIndex")));
			this.lblYear.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblYear.ImeMode")));
			this.lblYear.Location = ((System.Drawing.Point)(resources.GetObject("lblYear.Location")));
			this.lblYear.Name = "lblYear";
			this.lblYear.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblYear.RightToLeft")));
			this.lblYear.Size = ((System.Drawing.Size)(resources.GetObject("lblYear.Size")));
			this.lblYear.TabIndex = ((int)(resources.GetObject("lblYear.TabIndex")));
			this.lblYear.Text = resources.GetString("lblYear.Text");
			this.lblYear.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblYear.TextAlign")));
			this.lblYear.Visible = ((bool)(resources.GetObject("lblYear.Visible")));
			// 
			// lblMonth
			// 
			this.lblMonth.AccessibleDescription = resources.GetString("lblMonth.AccessibleDescription");
			this.lblMonth.AccessibleName = resources.GetString("lblMonth.AccessibleName");
			this.lblMonth.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblMonth.Anchor")));
			this.lblMonth.AutoSize = ((bool)(resources.GetObject("lblMonth.AutoSize")));
			this.lblMonth.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblMonth.Dock")));
			this.lblMonth.Enabled = ((bool)(resources.GetObject("lblMonth.Enabled")));
			this.lblMonth.Font = ((System.Drawing.Font)(resources.GetObject("lblMonth.Font")));
			this.lblMonth.ForeColor = System.Drawing.Color.Maroon;
			this.lblMonth.Image = ((System.Drawing.Image)(resources.GetObject("lblMonth.Image")));
			this.lblMonth.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblMonth.ImageAlign")));
			this.lblMonth.ImageIndex = ((int)(resources.GetObject("lblMonth.ImageIndex")));
			this.lblMonth.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblMonth.ImeMode")));
			this.lblMonth.Location = ((System.Drawing.Point)(resources.GetObject("lblMonth.Location")));
			this.lblMonth.Name = "lblMonth";
			this.lblMonth.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblMonth.RightToLeft")));
			this.lblMonth.Size = ((System.Drawing.Size)(resources.GetObject("lblMonth.Size")));
			this.lblMonth.TabIndex = ((int)(resources.GetObject("lblMonth.TabIndex")));
			this.lblMonth.Text = resources.GetString("lblMonth.Text");
			this.lblMonth.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblMonth.TextAlign")));
			this.lblMonth.Visible = ((bool)(resources.GetObject("lblMonth.Visible")));
			// 
			// txtCustomer
			// 
			this.txtCustomer.AccessibleDescription = resources.GetString("txtCustomer.AccessibleDescription");
			this.txtCustomer.AccessibleName = resources.GetString("txtCustomer.AccessibleName");
			this.txtCustomer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtCustomer.Anchor")));
			this.txtCustomer.AutoSize = ((bool)(resources.GetObject("txtCustomer.AutoSize")));
			this.txtCustomer.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtCustomer.BackgroundImage")));
			this.txtCustomer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtCustomer.Dock")));
			this.txtCustomer.Enabled = ((bool)(resources.GetObject("txtCustomer.Enabled")));
			this.txtCustomer.Font = ((System.Drawing.Font)(resources.GetObject("txtCustomer.Font")));
			this.txtCustomer.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtCustomer.ImeMode")));
			this.txtCustomer.Location = ((System.Drawing.Point)(resources.GetObject("txtCustomer.Location")));
			this.txtCustomer.MaxLength = ((int)(resources.GetObject("txtCustomer.MaxLength")));
			this.txtCustomer.Multiline = ((bool)(resources.GetObject("txtCustomer.Multiline")));
			this.txtCustomer.Name = "txtCustomer";
			this.txtCustomer.PasswordChar = ((char)(resources.GetObject("txtCustomer.PasswordChar")));
			this.txtCustomer.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtCustomer.RightToLeft")));
			this.txtCustomer.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("txtCustomer.ScrollBars")));
			this.txtCustomer.Size = ((System.Drawing.Size)(resources.GetObject("txtCustomer.Size")));
			this.txtCustomer.TabIndex = ((int)(resources.GetObject("txtCustomer.TabIndex")));
			this.txtCustomer.Text = resources.GetString("txtCustomer.Text");
			this.txtCustomer.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtCustomer.TextAlign")));
			this.txtCustomer.Visible = ((bool)(resources.GetObject("txtCustomer.Visible")));
			this.txtCustomer.WordWrap = ((bool)(resources.GetObject("txtCustomer.WordWrap")));
			this.txtCustomer.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCustomer_KeyDown);
			this.txtCustomer.Validating += new System.ComponentModel.CancelEventHandler(this.txtCustomer_Validating);
			// 
			// lblCustomer
			// 
			this.lblCustomer.AccessibleDescription = resources.GetString("lblCustomer.AccessibleDescription");
			this.lblCustomer.AccessibleName = resources.GetString("lblCustomer.AccessibleName");
			this.lblCustomer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblCustomer.Anchor")));
			this.lblCustomer.AutoSize = ((bool)(resources.GetObject("lblCustomer.AutoSize")));
			this.lblCustomer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblCustomer.Dock")));
			this.lblCustomer.Enabled = ((bool)(resources.GetObject("lblCustomer.Enabled")));
			this.lblCustomer.Font = ((System.Drawing.Font)(resources.GetObject("lblCustomer.Font")));
			this.lblCustomer.ForeColor = System.Drawing.Color.Maroon;
			this.lblCustomer.Image = ((System.Drawing.Image)(resources.GetObject("lblCustomer.Image")));
			this.lblCustomer.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCustomer.ImageAlign")));
			this.lblCustomer.ImageIndex = ((int)(resources.GetObject("lblCustomer.ImageIndex")));
			this.lblCustomer.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblCustomer.ImeMode")));
			this.lblCustomer.Location = ((System.Drawing.Point)(resources.GetObject("lblCustomer.Location")));
			this.lblCustomer.Name = "lblCustomer";
			this.lblCustomer.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblCustomer.RightToLeft")));
			this.lblCustomer.Size = ((System.Drawing.Size)(resources.GetObject("lblCustomer.Size")));
			this.lblCustomer.TabIndex = ((int)(resources.GetObject("lblCustomer.TabIndex")));
			this.lblCustomer.Text = resources.GetString("lblCustomer.Text");
			this.lblCustomer.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCustomer.TextAlign")));
			this.lblCustomer.Visible = ((bool)(resources.GetObject("lblCustomer.Visible")));
			// 
			// btnCustomer
			// 
			this.btnCustomer.AccessibleDescription = resources.GetString("btnCustomer.AccessibleDescription");
			this.btnCustomer.AccessibleName = resources.GetString("btnCustomer.AccessibleName");
			this.btnCustomer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCustomer.Anchor")));
			this.btnCustomer.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCustomer.BackgroundImage")));
			this.btnCustomer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCustomer.Dock")));
			this.btnCustomer.Enabled = ((bool)(resources.GetObject("btnCustomer.Enabled")));
			this.btnCustomer.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCustomer.FlatStyle")));
			this.btnCustomer.Font = ((System.Drawing.Font)(resources.GetObject("btnCustomer.Font")));
			this.btnCustomer.Image = ((System.Drawing.Image)(resources.GetObject("btnCustomer.Image")));
			this.btnCustomer.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCustomer.ImageAlign")));
			this.btnCustomer.ImageIndex = ((int)(resources.GetObject("btnCustomer.ImageIndex")));
			this.btnCustomer.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCustomer.ImeMode")));
			this.btnCustomer.Location = ((System.Drawing.Point)(resources.GetObject("btnCustomer.Location")));
			this.btnCustomer.Name = "btnCustomer";
			this.btnCustomer.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCustomer.RightToLeft")));
			this.btnCustomer.Size = ((System.Drawing.Size)(resources.GetObject("btnCustomer.Size")));
			this.btnCustomer.TabIndex = ((int)(resources.GetObject("btnCustomer.TabIndex")));
			this.btnCustomer.Text = resources.GetString("btnCustomer.Text");
			this.btnCustomer.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCustomer.TextAlign")));
			this.btnCustomer.Visible = ((bool)(resources.GetObject("btnCustomer.Visible")));
			this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
			// 
			// txtCustomerName
			// 
			this.txtCustomerName.AccessibleDescription = resources.GetString("txtCustomerName.AccessibleDescription");
			this.txtCustomerName.AccessibleName = resources.GetString("txtCustomerName.AccessibleName");
			this.txtCustomerName.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtCustomerName.Anchor")));
			this.txtCustomerName.AutoSize = ((bool)(resources.GetObject("txtCustomerName.AutoSize")));
			this.txtCustomerName.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtCustomerName.BackgroundImage")));
			this.txtCustomerName.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtCustomerName.Dock")));
			this.txtCustomerName.Enabled = ((bool)(resources.GetObject("txtCustomerName.Enabled")));
			this.txtCustomerName.Font = ((System.Drawing.Font)(resources.GetObject("txtCustomerName.Font")));
			this.txtCustomerName.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtCustomerName.ImeMode")));
			this.txtCustomerName.Location = ((System.Drawing.Point)(resources.GetObject("txtCustomerName.Location")));
			this.txtCustomerName.MaxLength = ((int)(resources.GetObject("txtCustomerName.MaxLength")));
			this.txtCustomerName.Multiline = ((bool)(resources.GetObject("txtCustomerName.Multiline")));
			this.txtCustomerName.Name = "txtCustomerName";
			this.txtCustomerName.PasswordChar = ((char)(resources.GetObject("txtCustomerName.PasswordChar")));
			this.txtCustomerName.ReadOnly = true;
			this.txtCustomerName.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtCustomerName.RightToLeft")));
			this.txtCustomerName.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("txtCustomerName.ScrollBars")));
			this.txtCustomerName.Size = ((System.Drawing.Size)(resources.GetObject("txtCustomerName.Size")));
			this.txtCustomerName.TabIndex = ((int)(resources.GetObject("txtCustomerName.TabIndex")));
			this.txtCustomerName.Text = resources.GetString("txtCustomerName.Text");
			this.txtCustomerName.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtCustomerName.TextAlign")));
			this.txtCustomerName.Visible = ((bool)(resources.GetObject("txtCustomerName.Visible")));
			this.txtCustomerName.WordWrap = ((bool)(resources.GetObject("txtCustomerName.WordWrap")));
			// 
			// btnSearch
			// 
			this.btnSearch.AccessibleDescription = resources.GetString("btnSearch.AccessibleDescription");
			this.btnSearch.AccessibleName = resources.GetString("btnSearch.AccessibleName");
			this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSearch.Anchor")));
			this.btnSearch.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSearch.BackgroundImage")));
			this.btnSearch.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSearch.Dock")));
			this.btnSearch.Enabled = ((bool)(resources.GetObject("btnSearch.Enabled")));
			this.btnSearch.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSearch.FlatStyle")));
			this.btnSearch.Font = ((System.Drawing.Font)(resources.GetObject("btnSearch.Font")));
			this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
			this.btnSearch.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSearch.ImageAlign")));
			this.btnSearch.ImageIndex = ((int)(resources.GetObject("btnSearch.ImageIndex")));
			this.btnSearch.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSearch.ImeMode")));
			this.btnSearch.Location = ((System.Drawing.Point)(resources.GetObject("btnSearch.Location")));
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSearch.RightToLeft")));
			this.btnSearch.Size = ((System.Drawing.Size)(resources.GetObject("btnSearch.Size")));
			this.btnSearch.TabIndex = ((int)(resources.GetObject("btnSearch.TabIndex")));
			this.btnSearch.Text = resources.GetString("btnSearch.Text");
			this.btnSearch.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSearch.TextAlign")));
			this.btnSearch.Visible = ((bool)(resources.GetObject("btnSearch.Visible")));
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// dgrdData
			// 
			this.dgrdData.AccessibleDescription = resources.GetString("dgrdData.AccessibleDescription");
			this.dgrdData.AccessibleName = resources.GetString("dgrdData.AccessibleName");
			this.dgrdData.AllowAddNew = ((bool)(resources.GetObject("dgrdData.AllowAddNew")));
			this.dgrdData.AllowArrows = ((bool)(resources.GetObject("dgrdData.AllowArrows")));
			this.dgrdData.AllowColMove = ((bool)(resources.GetObject("dgrdData.AllowColMove")));
			this.dgrdData.AllowColSelect = ((bool)(resources.GetObject("dgrdData.AllowColSelect")));
			this.dgrdData.AllowDelete = ((bool)(resources.GetObject("dgrdData.AllowDelete")));
			this.dgrdData.AllowDrag = ((bool)(resources.GetObject("dgrdData.AllowDrag")));
			this.dgrdData.AllowFilter = ((bool)(resources.GetObject("dgrdData.AllowFilter")));
			this.dgrdData.AllowHorizontalSplit = ((bool)(resources.GetObject("dgrdData.AllowHorizontalSplit")));
			this.dgrdData.AllowRowSelect = ((bool)(resources.GetObject("dgrdData.AllowRowSelect")));
			this.dgrdData.AllowSort = ((bool)(resources.GetObject("dgrdData.AllowSort")));
			this.dgrdData.AllowUpdate = ((bool)(resources.GetObject("dgrdData.AllowUpdate")));
			this.dgrdData.AllowUpdateOnBlur = ((bool)(resources.GetObject("dgrdData.AllowUpdateOnBlur")));
			this.dgrdData.AllowVerticalSplit = ((bool)(resources.GetObject("dgrdData.AllowVerticalSplit")));
			this.dgrdData.AlternatingRows = ((bool)(resources.GetObject("dgrdData.AlternatingRows")));
			this.dgrdData.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dgrdData.Anchor")));
			this.dgrdData.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dgrdData.BackgroundImage")));
			this.dgrdData.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("dgrdData.BorderStyle")));
			this.dgrdData.Caption = resources.GetString("dgrdData.Caption");
			this.dgrdData.CaptionHeight = ((int)(resources.GetObject("dgrdData.CaptionHeight")));
			this.dgrdData.CellTipsDelay = ((int)(resources.GetObject("dgrdData.CellTipsDelay")));
			this.dgrdData.CellTipsWidth = ((int)(resources.GetObject("dgrdData.CellTipsWidth")));
			this.dgrdData.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("dgrdData.ChildGrid")));
			this.dgrdData.CollapseColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.CollapseColor")));
			this.dgrdData.ColumnFooters = ((bool)(resources.GetObject("dgrdData.ColumnFooters")));
			this.dgrdData.ColumnHeaders = ((bool)(resources.GetObject("dgrdData.ColumnHeaders")));
			this.dgrdData.DefColWidth = ((int)(resources.GetObject("dgrdData.DefColWidth")));
			this.dgrdData.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dgrdData.Dock")));
			this.dgrdData.EditDropDown = ((bool)(resources.GetObject("dgrdData.EditDropDown")));
			this.dgrdData.EmptyRows = ((bool)(resources.GetObject("dgrdData.EmptyRows")));
			this.dgrdData.Enabled = ((bool)(resources.GetObject("dgrdData.Enabled")));
			this.dgrdData.ExpandColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.ExpandColor")));
			this.dgrdData.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("dgrdData.ExposeCellMode")));
			this.dgrdData.ExtendRightColumn = ((bool)(resources.GetObject("dgrdData.ExtendRightColumn")));
			this.dgrdData.FetchRowStyles = ((bool)(resources.GetObject("dgrdData.FetchRowStyles")));
			this.dgrdData.FilterBar = ((bool)(resources.GetObject("dgrdData.FilterBar")));
			this.dgrdData.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("dgrdData.FlatStyle")));
			this.dgrdData.Font = ((System.Drawing.Font)(resources.GetObject("dgrdData.Font")));
			this.dgrdData.GroupByAreaVisible = ((bool)(resources.GetObject("dgrdData.GroupByAreaVisible")));
			this.dgrdData.GroupByCaption = resources.GetString("dgrdData.GroupByCaption");
			this.dgrdData.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.dgrdData.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dgrdData.ImeMode")));
			this.dgrdData.LinesPerRow = ((int)(resources.GetObject("dgrdData.LinesPerRow")));
			this.dgrdData.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.Location")));
			this.dgrdData.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.dgrdData.Name = "dgrdData";
			this.dgrdData.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureAddnewRow")));
			this.dgrdData.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureCurrentRow")));
			this.dgrdData.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFilterBar")));
			this.dgrdData.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFooterRow")));
			this.dgrdData.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureHeaderRow")));
			this.dgrdData.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureModifiedRow")));
			this.dgrdData.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureStandardRow")));
			this.dgrdData.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("dgrdData.PreviewInfo.AllowSizing")));
			this.dgrdData.PreviewInfo.Caption = resources.GetString("dgrdData.PreviewInfo.Caption");
			this.dgrdData.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.PreviewInfo.Location")));
			this.dgrdData.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.PreviewInfo.Size")));
			this.dgrdData.PreviewInfo.ToolBars = ((bool)(resources.GetObject("dgrdData.PreviewInfo.ToolBars")));
			this.dgrdData.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("dgrdData.PreviewInfo.UIStrings.Content")));
			this.dgrdData.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("dgrdData.PreviewInfo.ZoomFactor")));
			this.dgrdData.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.MaxRowHeight")));
			this.dgrdData.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageFooter")));
			this.dgrdData.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageHeader")));
			this.dgrdData.PrintInfo.PageFooter = resources.GetString("dgrdData.PrintInfo.PageFooter");
			this.dgrdData.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageFooterHeight")));
			this.dgrdData.PrintInfo.PageHeader = resources.GetString("dgrdData.PrintInfo.PageHeader");
			this.dgrdData.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageHeaderHeight")));
			this.dgrdData.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("dgrdData.PrintInfo.PrintHorizontalSplits")));
			this.dgrdData.PrintInfo.ProgressCaption = resources.GetString("dgrdData.PrintInfo.ProgressCaption");
			this.dgrdData.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnFooters")));
			this.dgrdData.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnHeaders")));
			this.dgrdData.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatGridHeader")));
			this.dgrdData.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatSplitHeaders")));
			this.dgrdData.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowOptionsDialog")));
			this.dgrdData.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowProgressForm")));
			this.dgrdData.PrintInfo.ShowSelection = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowSelection")));
			this.dgrdData.PrintInfo.UseGridColors = ((bool)(resources.GetObject("dgrdData.PrintInfo.UseGridColors")));
			this.dgrdData.RecordSelectors = ((bool)(resources.GetObject("dgrdData.RecordSelectors")));
			this.dgrdData.RecordSelectorWidth = ((int)(resources.GetObject("dgrdData.RecordSelectorWidth")));
			this.dgrdData.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dgrdData.RightToLeft")));
			this.dgrdData.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color")));
			this.dgrdData.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style")));
			this.dgrdData.RowHeight = ((int)(resources.GetObject("dgrdData.RowHeight")));
			this.dgrdData.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.RowSubDividerColor")));
			this.dgrdData.ScrollTips = ((bool)(resources.GetObject("dgrdData.ScrollTips")));
			this.dgrdData.ScrollTrack = ((bool)(resources.GetObject("dgrdData.ScrollTrack")));
			this.dgrdData.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.Size")));
			this.dgrdData.SpringMode = ((bool)(resources.GetObject("dgrdData.SpringMode")));
			this.dgrdData.TabAcrossSplits = ((bool)(resources.GetObject("dgrdData.TabAcrossSplits")));
			this.dgrdData.TabIndex = ((int)(resources.GetObject("dgrdData.TabIndex")));
			this.dgrdData.Text = resources.GetString("dgrdData.Text");
			this.dgrdData.ViewCaptionWidth = ((int)(resources.GetObject("dgrdData.ViewCaptionWidth")));
			this.dgrdData.ViewColumnWidth = ((int)(resources.GetObject("dgrdData.ViewColumnWidth")));
			this.dgrdData.Visible = ((bool)(resources.GetObject("dgrdData.Visible")));
			this.dgrdData.WrapCellPointer = ((bool)(resources.GetObject("dgrdData.WrapCellPointer")));
			this.dgrdData.PropBag = resources.GetString("dgrdData.PropBag");
			// 
			// btnSave
			// 
			this.btnSave.AccessibleDescription = resources.GetString("btnSave.AccessibleDescription");
			this.btnSave.AccessibleName = resources.GetString("btnSave.AccessibleName");
			this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSave.Anchor")));
			this.btnSave.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSave.BackgroundImage")));
			this.btnSave.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSave.Dock")));
			this.btnSave.Enabled = ((bool)(resources.GetObject("btnSave.Enabled")));
			this.btnSave.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSave.FlatStyle")));
			this.btnSave.Font = ((System.Drawing.Font)(resources.GetObject("btnSave.Font")));
			this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image")));
			this.btnSave.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.ImageAlign")));
			this.btnSave.ImageIndex = ((int)(resources.GetObject("btnSave.ImageIndex")));
			this.btnSave.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSave.ImeMode")));
			this.btnSave.Location = ((System.Drawing.Point)(resources.GetObject("btnSave.Location")));
			this.btnSave.Name = "btnSave";
			this.btnSave.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSave.RightToLeft")));
			this.btnSave.Size = ((System.Drawing.Size)(resources.GetObject("btnSave.Size")));
			this.btnSave.TabIndex = ((int)(resources.GetObject("btnSave.TabIndex")));
			this.btnSave.Text = resources.GetString("btnSave.Text");
			this.btnSave.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.TextAlign")));
			this.btnSave.Visible = ((bool)(resources.GetObject("btnSave.Visible")));
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// btnClose
			// 
			this.btnClose.AccessibleDescription = resources.GetString("btnClose.AccessibleDescription");
			this.btnClose.AccessibleName = resources.GetString("btnClose.AccessibleName");
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnClose.Anchor")));
			this.btnClose.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnClose.BackgroundImage")));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnClose.Dock")));
			this.btnClose.Enabled = ((bool)(resources.GetObject("btnClose.Enabled")));
			this.btnClose.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnClose.FlatStyle")));
			this.btnClose.Font = ((System.Drawing.Font)(resources.GetObject("btnClose.Font")));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.ImageAlign")));
			this.btnClose.ImageIndex = ((int)(resources.GetObject("btnClose.ImageIndex")));
			this.btnClose.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnClose.ImeMode")));
			this.btnClose.Location = ((System.Drawing.Point)(resources.GetObject("btnClose.Location")));
			this.btnClose.Name = "btnClose";
			this.btnClose.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnClose.RightToLeft")));
			this.btnClose.Size = ((System.Drawing.Size)(resources.GetObject("btnClose.Size")));
			this.btnClose.TabIndex = ((int)(resources.GetObject("btnClose.TabIndex")));
			this.btnClose.Text = resources.GetString("btnClose.Text");
			this.btnClose.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.TextAlign")));
			this.btnClose.Visible = ((bool)(resources.GetObject("btnClose.Visible")));
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// SOAvoidDupleSaleOrdersDelivery
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.CancelButton = this.btnClose;
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnSave);
			this.Controls.Add(this.dgrdData);
			this.Controls.Add(this.txtCustomerName);
			this.Controls.Add(this.txtCustomer);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.btnCustomer);
			this.Controls.Add(this.lblCustomer);
			this.Controls.Add(this.lblMonth);
			this.Controls.Add(this.lblYear);
			this.Controls.Add(this.cboMonth);
			this.Controls.Add(this.cboYear);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "SOAvoidDupleSaleOrdersDelivery";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Load += new System.EventHandler(this.SOAvoidDupleSaleOrdersDelivery_Load);
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// SOAvoidDupleSaleOrdersDelivery_Load
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void SOAvoidDupleSaleOrdersDelivery_Load(object sender, System.EventArgs e)
		{
			const string METHOD_NAME = THIS + ".SOAvoidDupleSaleOrdersDelivery_Load()";
			try
			{
				//Set form security
				Security objSecurity = new Security();		
				
				if (objSecurity.SetRightForUserOnForm(this, SystemProperty.UserName) == 0)
				{
					// You don't have the right to view this item
					PCSMessageBox.Show(ErrorCode.MESSAGE_YOU_HAVE_NO_RIGHT_TO_VIEW, MessageBoxIcon.Warning);
					this.Close();
					return;
				}
				//Init Combo box
				cboMonth.Items.Clear();
				cboMonth.Items.Add(string.Empty);
				for (int i = 1; i < 13; i++)
				{
					cboMonth.Items.Add(i.ToString());
				}
				cboMonth.SelectedIndex = -1;

				cboYear.Items.Clear();
				cboYear.Items.Add(string.Empty);
				for (int i = 2000; i < 2051; i++)
				{
					cboYear.Items.Add(i.ToString());
				}
				cboYear.SelectedIndex = -1;
				//get grid layout
				dtbGridLayOut = FormControlComponents.StoreGridLayout(dgrdData);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// OpenSearchForm for selecting Customer
		/// </summary>
		/// <param name="pstrMethodName"></param>
		/// <param name="pblnAlwaysShowDialog"></param>
		/// <returns></returns>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private bool SelectCustomer(string pstrMethodName, bool pblnAlwaysShowDialog)
		{
			try				
			{
				Hashtable htbCriteria = new Hashtable();
				DataRowView drwResult = null;
				const string VIEW_VENDOR = "V_VendorCustomer";
				const string CUSTOMER_COLUMN = "Customer";
				//Add condition for customer
				htbCriteria.Add(CUSTOMER_COLUMN, 0);
				//Call OpenSearchForm for selecting Customer
				drwResult = FormControlComponents.OpenSearchForm(VIEW_VENDOR, MST_PartyTable.CODE_FLD, txtCustomer.Text, htbCriteria, pblnAlwaysShowDialog);
				
				// If has Master location matched searching condition, fill values to form's controls
				if(drwResult != null)
				{
					txtCustomer.Text = drwResult[MST_PartyTable.CODE_FLD].ToString();
					txtCustomer.Tag = int.Parse(drwResult[MST_PartyTable.PARTYID_FLD].ToString());
					txtCustomerName.Text = drwResult[MST_PartyTable.NAME_FLD].ToString();
					//Reset modify status
					txtCustomer.Modified = false;
				}
				else if(!pblnAlwaysShowDialog)
				{	
					txtCustomer.Tag = null;
					txtCustomer.Focus();
					return false;
				}

				return true;
			}
			catch (PCSException ex)
			{
				throw new PCSException(ex.mCode, pstrMethodName, ex);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}
		}
		/// <summary>
		/// btnCustomer_Click
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void btnCustomer_Click(object sender, System.EventArgs e)
		{
			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.WaitCursor;

			#endregion Code Inserted Automatically

			
			const string METHOD_NAME = THIS + ".btnCustomer_Click()";
			try
			{
				SelectCustomer(METHOD_NAME, true);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}

			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.Default;

			#endregion Code Inserted Automatically

			
		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.WaitCursor;

			#endregion Code Inserted Automatically

			
			this.Close();

			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.Default;

			#endregion Code Inserted Automatically

			
		}
		/// <summary>
		/// txtCustomer_Validating
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void txtCustomer_Validating(object sender, System.ComponentModel.CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".txtCustomer_Validating()";
			try
			{
				if (txtCustomer.Text == string.Empty)
				{
					txtCustomerName.Text = string.Empty;
					txtCustomer.Tag = null;
					return;
				}

				if (!txtCustomer.Modified) return;
				e.Cancel = !SelectCustomer(METHOD_NAME, false);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// Config the grid data
		/// </summary>
		/// <param name="pblnLock"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void ConfigGrid(bool pblnLock)
		{
			const string METHOD_NAME = THIS + ".ConfigGrid()";
			try
			{
				
				dgrdData.Enabled = true;
				for (int i =0; i <dgrdData.Splits[0].DisplayColumns.Count; i++)
				{
					dgrdData.Splits[0].DisplayColumns[i].Locked = true;
				}
				//dgrdData.Splits[0].DisplayColumns[SO_DeliveryScheduleTable.DELIVERYSCHEDULEID_FLD].Visible = true;
				dgrdData.Splits[0].DisplayColumns[SELECT].Locked = !pblnLock;
				dgrdData.Splits[0].DisplayColumns[SO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD].DataColumn.NumberFormat = Constants.DECIMAL_NUMBERFORMAT;
				dgrdData.Splits[0].DisplayColumns[PRO_WorkOrderDetailTable.LINE_FLD].Style.HorizontalAlignment = AlignHorzEnum.Center;
				dgrdData.Splits[0].DisplayColumns[SO_DeliveryScheduleTable.SCHEDULEDATE_FLD].Style.HorizontalAlignment = AlignHorzEnum.Center;
				dgrdData.Columns[SO_DeliveryScheduleTable.SCHEDULEDATE_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR;

			}
			catch (PCSException ex)
			{
				throw new PCSException(ex.mCode, METHOD_NAME, ex);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}
		}
		/// <summary>
		/// ValidateDataToSearch
		/// </summary>
		/// <returns></returns>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private bool ValidateDataToSearch()
		{
			const string METHOD_NAME = THIS + ".ValidateDataToSearch()";
			try
			{
				if (FormControlComponents.CheckMandatory(cboYear))
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Exclamation);
					cboYear.Focus();				
					return false;
				}
				if (FormControlComponents.CheckMandatory(cboMonth))
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Exclamation);
					cboMonth.Focus();				
					return false;
				}
				if (FormControlComponents.CheckMandatory(txtCustomer))
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Exclamation);
					txtCustomer.Focus();				
					return false;
				}
				return true;
			}
			catch (PCSException ex)
			{
				throw new PCSException(ex.mCode, METHOD_NAME, ex);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}
		}
		/// <summary>
		/// btnSearch_Click
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.WaitCursor;

			#endregion Code Inserted Automatically

			
			const string METHOD_NAME = THIS + ".btnSearch_Click()";
			try
			{
				if (ValidateDataToSearch())
				{
					DateTime dtmDateToSearch = new DateTime(int.Parse(cboYear.SelectedItem.ToString()), int.Parse(cboMonth.SelectedItem.ToString()), 1);
					AvoidDupleSODeliveryBO boAvoidDupleSODelivery = new AvoidDupleSODeliveryBO();
					dtbData = boAvoidDupleSODelivery.SearchDupleSO(dtmDateToSearch, int.Parse(txtCustomer.Tag.ToString()));
					dtbData.Columns.Add(SELECT, typeof(bool));
					dgrdData.DataSource = dtbData;
					for (int i = 0; i < dgrdData.RowCount; i++)
					{
						dgrdData[i, SELECT] = false;
						dgrdData[i, PRO_WorkOrderDetailTable.LINE_FLD] = i + 1;
					}
					//Restore layout
					FormControlComponents.RestoreGridLayout(dgrdData, dtbGridLayOut);			
					ConfigGrid(true);
				}
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}


			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.Default;

			#endregion Code Inserted Automatically

			
		}
		/// <summary>
		/// txtCustomer_KeyDown
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <Date>Friday, Feb 17 2006</Date>
		private void txtCustomer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			const string METHOD_NAME = THIS + ".txtCustomer_KeyDown()";
			try
			{
				if(e.KeyCode == Keys.F4)
					if(btnCustomer.Enabled)
						btnCustomer_Click(sender,e);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}

		}
		/// <summary>
		/// btnSave_Click
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, Feb 17 2006</date>
		private void btnSave_Click(object sender, System.EventArgs e)
		{
			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.WaitCursor;

			#endregion Code Inserted Automatically

			
			const string METHOD_NAME = THIS + ".btnSave_Click()";
			try
			{
				//Validating data
				if (dgrdData.RowCount == 0)
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_PO_APPROVE_NO_DATA_IN_GRID, MessageBoxIcon.Warning);
					dgrdData.Focus();
					// Code Inserted Automatically
#region Code Inserted Automatically
this.Cursor = Cursors.Default;
#endregion Code Inserted Automatically

					return;
				}
				int intChecked = 0;
				for (int j = 0; j < dgrdData.RowCount; j++)
				{
					if (dgrdData[j, SELECT].ToString() != false.ToString())
					{
						intChecked++;
					}
				}
				if (intChecked == 0) 
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_AVOID_SO_SELECT_ATLEAST_ONE, MessageBoxIcon.Warning);
					dgrdData.Row = 0;
					dgrdData.Col = dgrdData.Splits[0].DisplayColumns.IndexOf(dgrdData.Splits[0].DisplayColumns[SELECT]);
					dgrdData.Focus();
					// Code Inserted Automatically
#region Code Inserted Automatically
this.Cursor = Cursors.Default;
#endregion Code Inserted Automatically

					return;
				}
				if (intChecked == dgrdData.RowCount)
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_AVOID_SO_CANNOT_SELECT_ALL, MessageBoxIcon.Warning);
					//MessageBox.Show("You cannot select all!");
					dgrdData.Row = 0;
					dgrdData.Col = dgrdData.Splits[0].DisplayColumns.IndexOf(dgrdData.Splits[0].DisplayColumns[SELECT]);
					dgrdData.Focus();
					// Code Inserted Automatically
#region Code Inserted Automatically
this.Cursor = Cursors.Default;
#endregion Code Inserted Automatically

					return;
				}
				string strDeliveryScheduleID = " (";
				for (int i = 0; i < dgrdData.RowCount; i++)
				{
					if (dgrdData[i, SELECT].ToString() == true.ToString())
					{
						strDeliveryScheduleID = strDeliveryScheduleID + dgrdData[i, SO_DeliveryScheduleTable.DELIVERYSCHEDULEID_FLD].ToString() + ",";
					}
				}
				strDeliveryScheduleID = strDeliveryScheduleID + "0)";
				AvoidDupleSODeliveryBO boAvoidDupleSODelivery = new AvoidDupleSODeliveryBO();
				boAvoidDupleSODelivery.DeleteDupleSODelivery(strDeliveryScheduleID);
				//Re-load data to grid
				btnSearch_Click(null, null);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}

			// Code Inserted Automatically

			#region Code Inserted Automatically

			this.Cursor = Cursors.Default;

			#endregion Code Inserted Automatically

			
		}
	}
}
